using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using T2.WebSecurity.Data.Controllers.Interfaces;
using T2.WebSecurity.Data.Entities.Interfaces;
using T2.WebSecurity.Business.Entities.Interfaces;
using T2.WebSecurity.Business.Entities;
using T2.WebSecurity.Business.Builders;
using T2.WebSecurity.Business.Directors.Interface;
using T2.WebSecurity.Business.Entities.Search.Interfaces;

//--Change Management Control - Application Director  --**********************
//--Created By: trooks
//--Description: Application Director Class
//--Created Date: 03/07/2013 10:48:56
//--*************************************************************

namespace T2.WebSecurity.Business.Directors
{
	public partial class Application_Director_biz : IApplication_director_biz
	{
		
		public List<IApplication_biz> Construct (IApplication_biz _param, bool BuildUp, bool BuildDown)
		{
			Application_Builder build = new Application_Builder();
			List<IApplication_biz> retVal = build.BuildParts(_param);
			foreach(IApplication_biz item in retVal)
			{
				item.ApplicationRoles_List = BuildApplicationRolesList(item, false, BuildDown);
				item.ApplicationUser_List = BuildApplicationUserList(item, false, BuildDown);
				item.ApplicationProfileData_List = BuildApplicationProfileDataList(item, false, BuildDown);
		}
			return retVal;
		}
		public List<IApplication_biz> Construct (IApplicationSearch_biz _param, bool BuildUp, bool BuildDown)
		{
			Application_Builder build = new Application_Builder();
			List<IApplication_biz> retVal = build.BuildParts(_param);
			foreach(IApplication_biz item in retVal)
			{
				item.ApplicationRoles_List = BuildApplicationRolesList(item, false, BuildDown);
				item.ApplicationUser_List = BuildApplicationUserList(item, false, BuildDown);
				item.ApplicationProfileData_List = BuildApplicationProfileDataList(item, false, BuildDown);
		}
			return retVal;
		}
		private List<IApplicationRoles_biz> BuildApplicationRolesList(IApplication_biz _param, bool BuildUp, bool BuildDown)
		{
			List<IApplicationRoles_biz> retVal = new List<IApplicationRoles_biz>();
			if(BuildDown)
			{
			IApplicationRoles_biz ApplicationRolesParam = new ApplicationRoles_biz();
			ApplicationRolesParam.Action ="Application_ApplicationRoles_ByParent";
			ApplicationRolesParam.PageNumber = 1;
			ApplicationRolesParam.PageSize = 100;
			ApplicationRolesParam.SortType = "asc";
			ApplicationRolesParam.SortColumn = "ApplicationRoleId";
			ApplicationRolesParam.ApplicationID = _param.ApplicationID;
			ApplicationRoles_Builder builder = new ApplicationRoles_Builder();
			retVal = builder.BuildParts(ApplicationRolesParam);
			}
			return retVal;
		}
		private List<IApplicationUser_biz> BuildApplicationUserList(IApplication_biz _param, bool BuildUp, bool BuildDown)
		{
			List<IApplicationUser_biz> retVal = new List<IApplicationUser_biz>();
			if(BuildDown)
			{
			IApplicationUser_biz ApplicationUserParam = new ApplicationUser_biz();
			ApplicationUserParam.Action ="Application_ApplicationUser_ByParent";
			ApplicationUserParam.PageNumber = 1;
			ApplicationUserParam.PageSize = 100;
			ApplicationUserParam.SortType = "asc";
			ApplicationUserParam.SortColumn = "ApplicationUserID";
			ApplicationUserParam.ApplicationID = _param.ApplicationID;
			ApplicationUser_Builder builder = new ApplicationUser_Builder();
			retVal = builder.BuildParts(ApplicationUserParam);
			}
			return retVal;
		}
		private List<IApplicationProfileData_biz> BuildApplicationProfileDataList(IApplication_biz _param, bool BuildUp, bool BuildDown)
		{
			List<IApplicationProfileData_biz> retVal = new List<IApplicationProfileData_biz>();
			if(BuildDown)
			{
			IApplicationProfileData_biz ApplicationProfileDataParam = new ApplicationProfileData_biz();
			ApplicationProfileDataParam.Action ="Application_ApplicationProfileData_ByParent";
			ApplicationProfileDataParam.PageNumber = 1;
			ApplicationProfileDataParam.PageSize = 100;
			ApplicationProfileDataParam.SortType = "asc";
			ApplicationProfileDataParam.SortColumn = "ApplicationProfileDataID";
			ApplicationProfileDataParam.ApplicationID = _param.ApplicationID;
			ApplicationProfileData_Builder builder = new ApplicationProfileData_Builder();
			retVal = builder.BuildParts(ApplicationProfileDataParam);
			}
			return retVal;
		}
	}
}